﻿using System.ComponentModel;
using System.Xml.Serialization;
using TechMadeira.Data;
using TechMadeira.Data.Classes;

namespace TechMadeira.Workflows
{
    [XmlRoot("Order")]
    public class OrderWithStatus : Order, IOrderWithStatus
    {
        public OrderWithStatus()
        {
        }

        public OrderWithStatus( IOrder aOrder )
        {
            Order = aOrder;
            State = OrderWorkflow.Instance.Ordered;
        }

        private IOrderState mState = null;

        [Browsable( false ), XmlIgnore]
        public IOrderState State
        {
            get { return mState; } 
            set { mState = value; Notify(); }
        }

        [Browsable(false),XmlIgnore]
        public IOrder Order { get; private set; }

        public string Status
        {
            get { return State.Name; }
            set { State = OrderWorkflow.Instance.GetOrderByName( value ); }
        }


    }
}
